import { ActionTree } from "vuex"; // 校验规则
import { ProfileState, RootState } from "../types";
import {reqGuessCity, reqMsiteAddress} from "@/api/city";
import {AxiosResponse} from "axios";
import {state} from "@/store/profile/state";

export const actions: ActionTree<ProfileState, RootState> = {
    async setGeoHash({ commit }){
        let res = await reqGuessCity({  type: 'guess' });
        let geohash = res.data.latitude + ',' + res.data.longitude;
        commit('SAVE_GEOHASH', geohash);
    },
    async setPosi({commit}){
        let res = await  reqMsiteAddress(state.geohash);
        commit('SAVE_POIS',res.data.name)
    }
};
